package com.wq.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wq.common.PageResult;
import com.wq.common.Result;
import com.wq.dto.ArticleDeleteDTO;
import com.wq.dto.ArticleDetailDTO;
import com.wq.dto.ArticlePageDTO;
import com.wq.dto.ArticlePublishDTO;
import com.wq.service.ArticleService;
import com.wq.vo.ArticleDetailVO;
import com.wq.vo.ArticlePageVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/article")
public class ArticleController {
    @Resource
    private ArticleService articleService;
    @PostMapping("publish")
    public Result<Object> publish(@RequestBody ArticlePublishDTO articlePublishDTO) {
        articleService.publish(articlePublishDTO);
        return Result.success();
    }

    @PostMapping("list")
    public PageResult<ArticlePageVO> list(@RequestBody ArticlePageDTO articlePageDTO) {
        IPage<ArticlePageVO> page=articleService.getPage(articlePageDTO);
        return PageResult.success(page);
    }

    @PostMapping("delete")
    public Result<Object> delete(@RequestBody ArticleDeleteDTO articleDeleteDTO) {
        articleService.removeArticle(articleDeleteDTO);
        return Result.success();
    }

    @PostMapping("detail")
    public Result<ArticleDetailVO> detail(@RequestBody ArticleDetailDTO articleDetailDTO) {
        ArticleDetailVO articleDetailVO=articleService.detail(articleDetailDTO);
        return Result.success(articleDetailVO);
    }

    @PostMapping("update")
    public void  update(){

    }
}
